package com.example.server.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//统一响应结果
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    public static final String CODE_SUCCESS = "0";
    public static final String CODE_ERROR = "1";

    private String code;//状态码
    private String message;//提示信息
    private Object data;//响应数据


    public static Result success(Object data) {
        return new Result(CODE_SUCCESS,"操作成功",data);
    }

    public static Result success() {
        return new Result(CODE_SUCCESS,"操作成功",null);
    }

    public static Result error(String message) {
        return new Result(CODE_ERROR,message,null);
    }

    public static Result error(String code, String message) {
        return new Result(code,message,null);
    }

    public static Result error() {
        return new Result(CODE_ERROR,"系统错误",null);
    }

}
